package com.xhw.controller;


import com.xhw.dto.ActionResult;
import com.xhw.po.SysUser;
import com.xhw.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * TODO
 *
 * @author YoungKai
 * @date 2020/12/22 18:34
 */
@RestController
@RequestMapping("/userController")
public class UserController {

    @Autowired
    private UserService userService;


    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public ActionResult loginUser(String tel , String password) {
        System.out.println(tel);
        System.out.println(password);

        ActionResult actionResult;
        //根据手机号和密码查询对象
        SysUser user = userService.findUserByTelAndPassword(tel, password);
        System.out.println(user);
        if (user != null) {
            actionResult = new ActionResult(200, "登录成功", user);
        } else {
            actionResult = new ActionResult(400, "账户名或密码错误", null);
        }
        return actionResult;
    }
//    @GetMapping("hello")
//    public String hello(){
//        return "hello";
//    }
}
